﻿/// <reference Path="../jquery-1.3.2-vsdoc.js" />
// 加入到购物车
var productAddToCar = function (productId) {
    $.post(window.pl_addToCar_url, { ProductId: productId, count: 1, rnd: Math.random() }, function (result) {
        result = $(result);
        window.CloseDialog = function () { result.dialog("close") }
        result.dialog({ width: 500, modal: true, closeText: "×", close: function () { $(this).dialog("destroy") } });
        window.ReLoadMiNiCar();
    });
};
// 加入到收藏
var productAddToFavorite = function (productId) {
    $.post(window.addToFavorite_url, { productId: productId, rnd: Math.random() }, function (result) {
        result = $(result);
        window.CloseDialog = function () { result.dialog("close") }
        result.dialog({ width: 500, modal: true, closeText: "×", close: function () { $(this).dialog("destroy") } });
    });
}

$(function () {
    $(".dd1 div").eq(parseInt(window.pl_sort)).addClass("viewindex_curr");
    $(".viewindex dl").mouseover(function () { this.className = "hover"; })
        .bind("mouseleave", function () { this.className = ""; });
    $(".viewindex dd").hover(function () { $(this).css({ background: "#FFF3BF" }); },
        function () { $(this).css({ background: "#ffffff" }); });
    // 控制商品搜索条件查询显示
    var spanHtml = "";
    $(".f dd em a").each(function () {
        var text = $(this).text();
        if (text != "全部") { spanHtml += (spanHtml == "" ? "" : " + ") + text; }
    });
    $(".sort_codi span").html(spanHtml);
    if (spanHtml == "") { $(".sort_codi").hide(); };
    // 最新商品
    $.post(window.pl_productNewest_url, { id: window.pl_classifyId }, function (html) {
        $("#divNewestProduct").html(html);
    });
    // 历史记录
    var loadHtml, divHP = $("#divHistoryProduct");
    $.post(window.pl_productHistory_url, null, function (html) {
        loadHtml = divHP.html(); divHP.html(html);
    });
    $("#emHistoryProduct").click(function () {
        divHP.html(loadHtml);
        $.post(window.pl_productHistory_clear_url, null, function (html) {
            divHP.html(html);
        });
    });
});